using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Material.App;
using App.Material;

namespace Material.App
{
    public partial class FrmUtama : Form
    {
        private int childFormNumber = 0;
        //FrmUtama frmUtama = new FrmUtama();
        public FrmUtama()
        {
            InitializeComponent();
        }

        private void ShowNewForm(object sender, EventArgs e)
        {
            // Create a new instance of the child form.
            Form childForm = new Form();
            // Make it a child of this MDI form before showing it.
            childForm.MdiParent = this;
            childForm.Text = "Window " + childFormNumber++;
            childForm.Show();
        }

        private void OpenFile(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();
            openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            openFileDialog.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*";
            if (openFileDialog.ShowDialog(this) == DialogResult.OK)
            {
                string FileName = openFileDialog.FileName;
                // TODO: Add code here to open the file.
            }
        }

        private void SaveAsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();
            saveFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            saveFileDialog.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*";
            if (saveFileDialog.ShowDialog(this) == DialogResult.OK)
            {
                string FileName = saveFileDialog.FileName;
                // TODO: Add code here to save the current contents of the form to a file.
            }
        }

        private void ExitToolsStripMenuItem_Click(object sender, EventArgs e)
        {
            //DialogResult dr = MessageBox.Show("Benar akan keluar dari Aplikasi?", "Pesan", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            //if (dr == DialogResult.Yes)
            //{
                Application.Exit();
            //}
        }

        private void CutToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // TODO: Use System.Windows.Forms.Clipboard to insert the selected text or images into the clipboard
            FrmUser frmUser = new FrmUser();
            frmUser.MdiParent = this;
            frmUser.Height = this.Height;
            frmUser.Width = this.Width;
            frmUser.Show();
        }

        private void CopyToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // TODO: Use System.Windows.Forms.Clipboard to insert the selected text or images into the clipboard
        }

        private void PasteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // TODO: Use System.Windows.Forms.Clipboard.GetText() or System.Windows.Forms.GetData to retrieve information from the clipboard.
        }

        private void ToolBarToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //FrmPembBarang frm = new FrmPembBarang();
            //frm.MdiParent = this;//.frmUtama;
            //frm.WindowState = FormWindowState.Maximized;
            //frm.Height = this.Height;
            //frm.Width = this.Width;
            //frm.Show();
        }

        private void StatusBarToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FrmPenjBarangHRD frm = new FrmPenjBarangHRD();
            frm.MdiParent = this;
            frm.WindowState = FormWindowState.Maximized;
            frm.Height = this.Height;
            frm.Width = this.Width;
            frm.Show();
        }

        private void CascadeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.Cascade);
        }

        private void TileVerticleToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.TileVertical);
        }

        private void TileHorizontalToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.TileHorizontal);
        }

        private void ArrangeIconsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.ArrangeIcons);
        }

        private void CloseAllToolStripMenuItem_Click(object sender, EventArgs e)
        {
            foreach (Form childForm in MdiChildren)
            {
                childForm.Close();
            }
        }

        private void undoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FrmSatuan frmSatuan = new FrmSatuan();
            frmSatuan.MdiParent = this;//.frmUtama;
            frmSatuan.WindowState = FormWindowState.Maximized;


            frmSatuan.Height = this.Height;
            frmSatuan.Width = this.Width;

            frmSatuan.Show();
        }

        private void redoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FrmKelompok frmKelompok = new FrmKelompok();
            frmKelompok.MdiParent = this;
            frmKelompok.Height = this.Height;
            frmKelompok.Width = this.Width;
            frmKelompok.Show();

            
        }

        private void daftarBarangToolStripMenuItem_Click(object sender, EventArgs e)
        {
            
        }

        private void cariDataBarangToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FrmInqueryBarang frmDaftar = new FrmInqueryBarang();
            frmDaftar.MdiParent = this;

            frmDaftar.Height = this.Height;
            frmDaftar.Width = this.Width;

            frmDaftar.Show();
        }

        private void FrmUtama_FormClosed(object sender, FormClosedEventArgs e)
        {
            Application.Exit();
        }

        private void barangToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //toolStrip.Visible = toolBarToolStripMenuItem.Checked;
            FrmBarang frmBarang = new FrmBarang();
            frmBarang.MdiParent = this;
            frmBarang.Height = this.Height;
            frmBarang.Width = this.Width;
            frmBarang.Show();
        }

        private void piutangToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FrmHutangHDR frm = new FrmHutangHDR();
            frm.MdiParent = this;
            frm.Height = this.Height;
            frm.Width = this.Width;
            frm.Show();
        }

        private void laporanPiutangToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FrmDispPiutang frm = new FrmDispPiutang();
            frm.ShowDialog();
        }

        private void logToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Hide();
            FrmLogin frm = new FrmLogin();
            frm.ShowDialog();
        }

        private void backupDatabaseToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            FrmBackupDB frm = new FrmBackupDB();
            frm.ShowDialog();
        }

        private void dataBarangToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FrmDipsPembBarang frm = new FrmDipsPembBarang();
            frm.ShowDialog();
        }

        private void FrmUtama_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (DialogResult.Yes != MessageBox.Show(

            "Benar Akan Keluar Dari Aplikasi..?",

            "Pesan",

             MessageBoxButtons.YesNo,

             MessageBoxIcon.Question,

             MessageBoxDefaultButton.Button2))
            {

                e.Cancel = true;

            }
        }

        private void cariDataPiutangToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FrmInqueryPiutang frm = new FrmInqueryPiutang();
            frm.MdiParent = this;
            frm.Width = this.Width;
            frm.Height = this.Height;
            frm.Show();
        }

        private void FrmUtama_Load(object sender, EventArgs e)
        {
            //Gets forms that represent the MDI child forms 
            //that are parented to this form in an array 
            Form[] charr = this.MdiChildren;

            //For each child form set the window state to Maximized 
            foreach (Form chform in charr)
                chform.WindowState = FormWindowState.Maximized;
        }

        private void penjualanBarangToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FrmPencarianPenjualan frm = new FrmPencarianPenjualan();
            frm.MdiParent = this;
            frm.Width = this.Width;
            frm.Height = this.Height;
            frm.Show();
        }

        private void pembelianBarangToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FrmPencarianPembelian frm = new FrmPencarianPembelian();
            frm.MdiParent = this;
            frm.Width = this.Width;
            frm.Height = this.Height;
            frm.Show();
        }
    }
}
